/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package src.report.deposit;

import java.util.List;
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;
import src.domain.deposit.Bilyet;

/**
 *
 * @author Yusup Jauhari Shandi <in.visi>
 */
public class RptBilyetsimDS implements JRDataSource{
    private int index = -1;
    
    List<Bilyet> bilyets;
    
    public RptBilyetsimDS(List<Bilyet> sim) {
        super();
        this.bilyets = sim;
    }
    
    @Override
    public boolean next() throws JRException {
        index++;
        return (index < bilyets.size());
    }

    @Override
    public Object getFieldValue(JRField jrf) throws JRException {
        Object value = null;

	String fieldName = jrf.getName();
        switch (fieldName) {
            case "date": value = bilyets.get(index).getBilyetDate(); break;
            case "interest": value = bilyets.get(index).getInterestAmount(); break;
            case "tax": value = bilyets.get(index).getTaxAmount(); break;
        }
	return value;
    }
    
}
